package com.zl.learning.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

/**
 * Created by zhaolei on 2017/4/9.
 */
public class ParseAnn {
    public static void main(String[] args) {
        Class<Child> c = Child.class;
        boolean isExis = c.isAnnotationPresent(Description.class);
        if (isExis) {
            Description d = (Description) c.getAnnotation(Description.class);
            System.out.println(d.value());
        }
        Method[] ms = c.getMethods();
        for (Method m : ms) {
            boolean isMExist = m.isAnnotationPresent(Description.class);
            if (isMExist) {
                Description d = m.getAnnotation(Description.class);
                System.out.println(d.value());
            }
        }
        for (Method m : ms) {
            Annotation[] as = m.getAnnotations();
            for (Annotation a : as) {
                System.out.println(a);
                if (a instanceof Description) {
                    Description d = (Description) a;
                    System.out.println(d.value());
                }
            }
        }
    }
}
